package com.cc.moxingvoice;

import android.app.Application;

import com.iflytek.cloud.SpeechConstant;
import com.iflytek.cloud.SpeechUtility;
import com.mob.MobSDK;
import com.superc.cframework.utils.LogUtil;
import com.superc.cframework.utils.ToastUtil;
import com.umeng.commonsdk.UMConfigure;

import java.util.HashMap;

import cn.sharesdk.facebook.Facebook;
import cn.sharesdk.framework.ShareSDK;
import cn.sharesdk.sina.weibo.SinaWeibo;
import cn.sharesdk.tencent.qq.QQ;
import cn.sharesdk.tencent.qzone.QZone;
import cn.sharesdk.twitter.Twitter;
import cn.sharesdk.wechat.friends.Wechat;
import cn.sharesdk.wechat.moments.WechatMoments;

/**
 * 创建日期：2017/10/30 on 15:23
 * 描述：项目Application，单例设计模式
 * 作者：郭士超
 * QQ：1169380200
 */

public class MyApplication extends Application{

    private volatile static MyApplication instance;

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;

        LogUtil.isDebug = false;   // 打包一定要关闭Log

        // mob 初始化
        MobSDK.init(this,"24535667ed96a", "1f3d87114a3abef46a623d8f3255bd68");
        initMobSDK();
        /**
         * 初始化common库
         * 参数1:上下文，不能为空
         * 参数2:设备类型，UMConfigure.DEVICE_TYPE_PHONE为手机、UMConfigure.DEVICE_TYPE_BOX为盒子，默认为手机
         * 参数3:Push推送业务的secret
         */
        UMConfigure.init(this, UMConfigure.DEVICE_TYPE_PHONE, null);
        UMConfigure.setLogEnabled(true);

        SpeechUtility.createUtility(getApplicationContext(), SpeechConstant.APPID +"=5a9cd88c");
    }

    public static MyApplication getInstance() {
        if(instance == null) {
            synchronized(MyApplication.class) {
                if(instance == null) {
                    instance = new MyApplication();
                }
            }
        }
        return instance;
    }

    private void initMobSDK(){
        HashMap<String, Object> wechat = new HashMap<String, Object>();
        wechat.put("Id", "1");
        wechat.put("SortId", "1");
        wechat.put("AppId", "wx8d573dbce74f4026");
        wechat.put("AppSecret", "662a735e9b3d8fd8eba0bfbf9876fe4e");
        wechat.put("BypassApproval", "false");
        wechat.put("Enable", "true");
        ShareSDK.setPlatformDevInfo(Wechat.NAME, wechat);
        wechat.put("SortId", "2");
        ShareSDK.setPlatformDevInfo(WechatMoments.NAME, wechat);

        HashMap<String, Object> qq = new HashMap<String, Object>();
        qq.put("Id", "3");
        qq.put("SortId", "3");
        qq.put("AppId", "1106450670");
        qq.put("AppKey", "RrpLS9Lw53iIVjyu");
        qq.put("BypassApproval", "false");
        qq.put("ShareByAppClient", "true");
        qq.put("Enable", "true");
        ShareSDK.setPlatformDevInfo(QQ.NAME, qq);
        qq.put("SortId", "4");
        ShareSDK.setPlatformDevInfo(QZone.NAME, qq);

        HashMap<String, Object> sinaWeibo = new HashMap<String, Object>();
        sinaWeibo.put("Id", "5");
        sinaWeibo.put("SortId", "5");
        sinaWeibo.put("AppKey", "2726738517");
        sinaWeibo.put("AppSecret", "a9f3e2ee641ee1674032305f703a5517");
        sinaWeibo.put("RedirectUrl", "http://www.baidu.com");
        sinaWeibo.put("BypassApproval", "false");
        sinaWeibo.put("ShareByAppClient", "true");
        sinaWeibo.put("Enable", "true");
        ShareSDK.setPlatformDevInfo(SinaWeibo.NAME, sinaWeibo);

        HashMap<String, Object> facebook = new HashMap<String, Object>();
        facebook.put("Id", "6");
        facebook.put("SortId", "6");
        facebook.put("ConsumerKey", "1412473428822331");
        facebook.put("ConsumerSecret", "a42f4f3f867dc947b9ed6020c2e93558");
        facebook.put("RedirectUrl", "https://mob.com");
        facebook.put("BypassApproval", "true");
        facebook.put("ShareByAppClient", "true");
        facebook.put("Enable", "true");
        ShareSDK.setPlatformDevInfo(Facebook.NAME, facebook);

        HashMap<String, Object> twitter = new HashMap<String, Object>();
        twitter.put("Id", "7");
        twitter.put("SortId", "7");
        twitter.put("ConsumerKey", "LRBM0H75rWrU9gNHvlEAA2aOy");
        twitter.put("ConsumerSecret", "gbeWsZvA9ELJSdoBzJ5oLKX0TU09UOwrzdGfo9Tg7DjyGuMe8G");
        twitter.put("CallbackUrl", "https://mob.com");
        twitter.put("BypassApproval", "true");
        twitter.put("ShareByAppClient", "true");
        twitter.put("Enable", "true");
        ShareSDK.setPlatformDevInfo(Twitter.NAME, twitter);

    }

}
